﻿/*
5
1
2
3
4
5
0 1
1 3
*/
int length = Convert.ToInt32(Console.ReadLine()); // 数组长度
int[] nums = new int[length]; // 分配空间
int[] sumArr = new int[length]; // 前缀和数组
int sum = 0;

// 构建数组
for (int i = 0; i < length; i++)
{
    nums[i] = Convert.ToInt32(Console.ReadLine());
    sum += nums[i];
    sumArr[i] = sum;
}

// 求区间和
while (true)
{
    string[] blocks = Console.ReadLine().Split(' ');
    if (blocks.Length == 2)
    {
        int start = Convert.ToInt32(blocks[0]);
        int end = Convert.ToInt32(blocks[1]);

        if (start == 0)
        {
            Console.WriteLine(sumArr[end]);
        }
        else
        {
            Console.WriteLine(sumArr[end] - sumArr[start - 1]);
        }
    }
    else
    {
        break;
    }
}


